<?php
/**注意此文档为UTF-8的编码.
 * Created on 2010-5-17
 *
 * @author EXT <isrn@qq.com>
 *
 */
require_once '../../includes/global.php';

function items_config($id,$type,$tree_id)
{
	require_once '../../includes/config/items_config.php';
	foreach($type_array as $arrow=>$data){
		if($data['value'] == $type&&$data['param']==1){
			$config=$data['config'];
		}
	}

	function item_tpl($js,$width){
		return "{
				                columnWidth :".$width.",
				                baseCls:'x-plain',
				                layout : 'form',
				                border:false,
				                items : [".$js."]
				            }";

	}
	foreach($config as $key=>$value){
		switch($value['type']){
    		case 'combo':{
        		$str.=item_tpl('{xtype:"combo",
        		id:"combo",
        		layout:"form",
        		fieldLabel:"'.$value['lable'].'",
        		width:200,
        		anchor:"100%",
        		mode:"local",
        		displayField:"value",
        		triggerAction:"all",
        		readOnly:true,
        		store:new Ext.data.SimpleStore({
        			fields:["id","value"]
        			})
        		}',0.4);
        		break;
    		}
    		case 'button':{
        		if($value['fun']!=''){
        			$handle=',handler:'.$value['fun'];
        			$fun.=$fun_database[$value['fun']];
        		}else
        			$handle='';
        			$fun.='';
        			$str.='{baseCls:"x-plain",columnWidth:.1,bodyStyle:"padding-left:20px",items:{"xtype":"button","text":"'.$value['text'].'"'.$handle.'}}';
        		break;
    		}
    		default:{
        		$str.=item_tpl("{xtype: '".$value['type']."', fieldLabel: '".$value['lable']."'}",$value['width']);
        		if($key<count($config)-1){
        			$str.=',';
        		}
        		break;
    		}
    	}
	}
	$objResponse = new xajaxResponse();
	$core="var formpanel = new Ext.FormPanel({
				id:'formpanel',
                autoHeight: true,
                autoWidth: true,
                title: false,
                labelWidth : 80,
                border:false,
                layout: 'form',
                border:false,
                bodyStyle : 'padding:6px',
                renderTo: 'activity-".$id."',
                items :[{
				        layout : 'column',
				        border:false,
				        id:'add_items',
				        items : [$str]
				    }]
              });";
    $core.=$fun;
	$objResponse->script($core);
	return $objResponse;
}
$xajax = new xajax();
$xajax->registerFunction("items_config");
$xajax->processRequest();
?>